package com.supor.aiot.mine.ui.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.supor.aiot.common.app.Constants;
import com.supor.aiot.common.entity.DeviceInfo;
import com.supor.aiot.mine.R;
import com.supor.aiot.mine.bean.SelectDevice;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * ---------------------------------------------------------------- <br>
 * Copyright (C) 2014-2020, by het, Shenzhen, All rights reserved.  <br>
 * ---------------------------------------------------------------- <br>
 * <p>
 * 描述: DeviceAdapter <br>
 * 作者: lei <br>
 * 日期: 2021/7/16 <br>
 */
public class DeviceAdapter extends BaseQuickAdapter<SelectDevice, BaseViewHolder> {

    public DeviceAdapter(List<SelectDevice> dataList) {
        super(R.layout.item_wish_bind_device, dataList);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, SelectDevice device) {
        DeviceInfo data = device.deviceInfo;
        View item = holder.itemView.findViewById(R.id.cl_device);
        if (device.isSelect) {
            item.setSelected(true);
        } else {
            item.setSelected(false);
        }
        if (Constants.Type.CHEF_MACHINE.equalsIgnoreCase(data.pid)) {
            holder.setImageResource(R.id.iv_icon, R.mipmap.ic_device_chief_machine);
            holder.setText(R.id.tv_name, Constants.Value.CHEF_MACHINE);
            holder.setText(R.id.tv_tip, Constants.Value.CHEF_MACHINE_LABEL);
        } else if (Constants.Type.AIR_FRYER.equalsIgnoreCase(data.pid)) {
            holder.setImageResource(R.id.iv_icon, R.mipmap.ic_device_air_fryer);
            holder.setText(R.id.tv_name, Constants.Value.AIR_FRYER);
            holder.setText(R.id.tv_tip, Constants.Value.AIR_FRYER_LABEL);
        } else if (Constants.Type.AUTO_RICE_COOKER.equalsIgnoreCase(data.pid)) {
            holder.setImageResource(R.id.iv_icon, R.mipmap.ic_device_auto_rice_cooker);
            holder.setText(R.id.tv_name, Constants.Value.AIR_FRYER);
            holder.setText(R.id.tv_tip, Constants.Value.AIR_FRYER_LABEL);
        } else {
            holder.setImageResource(R.id.iv_icon, R.mipmap.ic_device_health_pot);
            holder.setText(R.id.tv_name, Constants.Value.AIR_FRYER);
            holder.setText(R.id.tv_tip, Constants.Value.AIR_FRYER_LABEL);
        }
    }
}
